package main

import (
	"fmt"
	"time"
)

//定义结构体 Address 和 VCard，后者包含一个人的名字、地址编号、出生日期和图像，试着选择正确的数据类型。构建一个自己的 vcard 并打印它的内容。

func main() {
	//addr1 is a pointer to a Address instance
	addr1 := &Address{"Elfenstraat", 12, "", "", "2600", "Mechelen", "België"}
	addr2 := &Address{"Heideland", 28, "", "", "2640", "Mortsel", "België"}
	addrs := make(map[string]*Address)
	addrs["youth"] = addr1
	addrs["now"] = addr2
	birthdt := time.Date(1956, 1, 17, 15, 4, 5, 0, time.Local)
	photo := "MyDocuments/MyPhotos/photo1.jpg"
	vcard := &VCard{"Ivo", "Balbaert", "", birthdt, photo, addrs}
	fmt.Printf("Here is the full VCard: %v\n", vcard)
	fmt.Printf("My Addresses are:\n %v\n %v", addr1, addr2)
}

type Address struct {
	Street            string
	HouseNumber       uint32
	HouseNumbserAddOn string
	PoBox             string
	ZipCode           string
	City              string
	Country           string
}

func (a Address) String() string {
	return fmt.Sprintf("%s %d %s %s %s %s %s", a.Street, a.HouseNumber, a.HouseNumbserAddOn, a.PoBox, a.ZipCode, a.City, a.Country)
}

type VCard struct {
	FirstName string
	LastName  string
	NickName  string
	BirthDate time.Time
	Photo     string
	Addresses map[string]*Address
}

func (V VCard) String() string {
	return fmt.Sprintf("%s %s %s %s %v", V.FirstName, V.LastName, V.NickName, V.BirthDate, V.Addresses)
}
